
package vistas;

import controladores.CListadoIngrediente;
import controladores.CListadoProducto;
import java.util.Vector;
import javax.swing.JButton;
import modelos.MProducto;
import modelos.MTabla;


public class VListadoProducto extends javax.swing.JFrame {
    private Vector<JButton> botones;
    private CListadoProducto control;
    private MTabla modeloTabla;
    private Vector<String> fila;
  

    public VListadoProducto() {
        initComponents();
        modeloTabla= new MTabla();
        control = new  CListadoProducto(this);
        fila= new Vector<String>();

        tblProducto.setModel(modeloTabla);

        fila.add("Producto");
        fila.add("Monto Total Generado");
        fila.add("Cantidad Total Vendida");
        modeloTabla.setColumnIdentifiers(fila);
        
        btnCancelar.addActionListener(control);
        btnConsultar.addActionListener(control);
        rbtnAsces.addActionListener(control);
        rbtnDesces.addActionListener(control);
        btnSalir.addActionListener(control);
    }

    public void agregarFila(String[] v){
        fila = new Vector<String>();
        for (int i = 0; i < v.length; i++)
            fila.add(v[i]);
        modeloTabla.addRow(fila);
    }

    public void  reiniciar() {
        modeloTabla.setRowCount(0);
    }
    


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblProducto = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
         rbtnAsces = new javax.swing.JRadioButton("Asces");
        rbtnDesces = new javax.swing.JRadioButton("Desces");
        jLabel4 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        btnConsultar = new javax.swing.JButton("Consultar");
        btnCancelar = new javax.swing.JButton("Cancelar");
        btnSalir = new javax.swing.JButton("Salir");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Listados de Productos");
        getContentPane().setLayout(null);

        tblProducto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblProducto);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(30, 90, 520, 260);
        jScrollPane2.setBackground(new java.awt.Color(255,255,255));

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15));
        jLabel1.setText("Forma de Ordenar");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(30, 40, 160, 40);

        buttonGroup1.add(rbtnAsces);
        rbtnAsces.setFont(new java.awt.Font("Ubuntu", 1, 15));
        rbtnAsces.setText("Ascendentemente");
        getContentPane().add(rbtnAsces);
        rbtnAsces.setBounds(186, 50, 190, 22);
        rbtnAsces.setBackground(new java.awt.Color(255,255,255));

        buttonGroup1.add(rbtnDesces);
        rbtnDesces.setFont(new java.awt.Font("Ubuntu", 1, 15));
        rbtnDesces.setText("Descendentemente");
        getContentPane().add(rbtnDesces);
        rbtnDesces.setBounds(377, 50, 190, 22);
        rbtnDesces.setBackground(new java.awt.Color(255,255,255));

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15));
        jLabel4.setText("Listado de Productos");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(180, 0, 190, 30);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(null);

        btnConsultar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnConsultar.setText("Consultar");
        jPanel1.add(btnConsultar);
        btnConsultar.setBounds(20, 20, 120, 30);

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnCancelar.setText("Cancelar");
        jPanel1.add(btnCancelar);
        btnCancelar.setBounds(20, 60, 120, 30);

        btnSalir.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnSalir.setText("Salir");
        jPanel1.add(btnSalir);
        btnSalir.setBounds(20, 100, 120, 30);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(210, 360, 160, 140);
        jPanel1.setBackground(new java.awt.Color(255,255,255));

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 575, 536);
        getContentPane().setBackground(new java.awt.Color(14,151,255));
    }// </editor-fold>//GEN-END:initComponents


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VListadoProducto().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JRadioButton rbtnAsces;
    private javax.swing.JRadioButton rbtnDesces;
    private javax.swing.JTable tblProducto;
    // End of variables declaration//GEN-END:variables

}
